package org.example.c04并发;

import org.junit.Test;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * <p>
 *
 * @author: Yuanwl
 * @date: 2020/5/18 14:59
 */
public class s03原子类 {

    @Test
    public void AtomicReferenceTest() {
        List<BigDecimal> arr = Arrays.asList(BigDecimal.ONE, BigDecimal.TEN, BigDecimal.ONE);
        AtomicReference<BigDecimal> totalInvoiceAmt = new AtomicReference<>(BigDecimal.ZERO);
        arr.stream().forEach(i -> {
            totalInvoiceAmt.set(totalInvoiceAmt.get().add(i));
        });
        System.err.println(totalInvoiceAmt);
    }
}
